﻿<Window x:Class="RentAWorker.Management.Shell.Shell"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.codeplex.com/CompositeWPF"
    Title="Composite WPF Project" Width="800" Height="600">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BoolVisConverter" />
    </Window.Resources>
    <DockPanel LastChildFill="True">
        <ToolBar DockPanel.Dock="Top" Height="25" Name="MainToolbar" />
        <StatusBar Name="Statusbar" DockPanel.Dock="Bottom" Height="20" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TabControl cal:RegionManager.RegionName="MainRegion" Margin="5">
                <TabControl.Resources>
                    <Style TargetType="TabItem">
                        <Setter Property="HeaderTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <ContentPresenter>
                                            <ContentPresenter.Content>
                                                <Binding Path="Content.DataContext.HeaderInfo">
                                                    <Binding.RelativeSource>
                                                        <RelativeSource Mode="FindAncestor"
                                                                    AncestorType="{x:Type TabItem}"/>
                                                    </Binding.RelativeSource>
                                                </Binding>
                                            </ContentPresenter.Content>
                                        </ContentPresenter>
                                        <Button Margin="8,0,0,0" Width="16" Height="16"
                                            Visibility="{Binding Path=Content.DataContext.CanClose, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type TabItem}}, Converter={StaticResource BoolVisConverter}}"
                                            Command="{Binding Path=CloseTabCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type Window}}}"
                                            CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type TabItem}},Path=Content}"
                                            HorizontalContentAlignment="Center"
                                            VerticalContentAlignment="Center">
                                            <Grid>
                                                <Canvas Width="8" Height="8">
                                                    <Line X1="2" X2="6" Y1="2" Y2="6" Stroke="Black" StrokeThickness="1"/>
                                                    <Line X1="6" X2="2" Y1="2" Y2="6" Stroke="Black" StrokeThickness="1"/>
                                                </Canvas>
                                            </Grid>
                                        </Button>
                                    </StackPanel>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </TabControl.Resources>
            </TabControl>

            <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" 
                          Height="5" ResizeDirection="Rows"  />

            <ContentControl cal:RegionManager.RegionName="DetailsRegion" Grid.Row="2" />
        </Grid>
    </DockPanel>
</Window>
